package com.woniu.woniu_bx.controller;
import com.woniu.woniu_bx.pojo.GoodsComment;
import com.woniu.woniu_bx.pojo.ResponseEntity;
import com.woniu.woniu_bx.service.GoodsCommentService;
import com.woniu.woniu_bx.utils.GetCurrentTime;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品评论控制器
 *
 * @author sjy
 * @create 2022-08-31 12:17
 */
@RestController
@Slf4j
@Validated
@RequestMapping("/goodsComment")
@CrossOrigin
public class GoodsCommentController {
    @Autowired
    private GoodsCommentService goodsCommentService;
    /**
     * 发布评论
     *
     * @param goodsComment
     * @return
     */
    @RequestMapping("add")
    public ResponseEntity postComment(@RequestBody GoodsComment goodsComment) {
        String currentTime = GetCurrentTime.getCurrentTime();
        goodsComment.setTime(currentTime);
        goodsCommentService.save(goodsComment);
        return ResponseEntity.SUCCESS("发布成功", null);
    }
}
